from django.db import models

# Create your models here.


# 用户表
class user(models.Model):
    user_id = models.AutoField(primary_key=True)
    username = models.CharField(max_length=50)
    password = models.CharField(max_length=128)
    phone = models.CharField(max_length=15)
    email = models.EmailField(null=True, blank=True)
    birthday = models.DateField(blank=True, null=True)
    # 省份
    province = models.CharField(max_length=100, null=True, blank=True)
    # 城市
    city = models.CharField(max_length=100, null=True, blank=True)
    # 区/县
    country = models.CharField(max_length=100, null=True, blank=True)
    introduce = models.CharField(max_length=200, blank=True, null=True, default="向其他小伙伴介绍一下你自己吧")
    gender = models.CharField(max_length=6, blank=True, null=True, default="")
    # 头像
    avatar = models.ImageField(upload_to='avatar', null=True, blank=True, verbose_name='头像')

    def __str__(self):
        return self.username

    class Meta:
        db_table = 'user'


# 验证码表（用于存放验证码）
class Code(models.Model):
    # 验证码id
    code_id = models.AutoField(primary_key=True)
    # 用户邮箱
    email = models.EmailField(max_length=255)
    # 验证码
    code = models.CharField(max_length=10)
    # 时间
    create_time = models.DateTimeField(blank=True)
    # 目前状况，1为未被使用，0为已经使用
    status = models.IntegerField(blank=True, default=1)

    def __str__(self):
        return self.code

    class Meta:
        db_table = 'code'




